package cn.pan;

import cn.pan.congiguration.EsConfiguration;
import cn.pan.service.EsRestService;
import org.apache.http.HttpHost;
import org.apache.log4j.Logger;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
public class EsfilesearchApplication {

    public static void main(String[] args) {

        SpringApplication.run(EsfilesearchApplication.class, args);
    }

    @Autowired
    EsConfiguration esConfiguration;

    @Bean
    public RestHighLevelClient restHighLevelClient() {

        RestHighLevelClient client = new RestHighLevelClient(
                RestClient.builder(
                        new HttpHost("10.55.10.4", 9200, esConfiguration.getSchema()),
                        new HttpHost("10.55.10.4", 9201, esConfiguration.getSchema()),
                        new HttpHost("10.55.10.3", 9202, esConfiguration.getSchema())
                        ));

        return client;
    }
}
